<?php

use console\db\channels\TransferTableMigration;
use yii\db\Query;

/**
 * 球迷学院用户关卡迁移
 * 
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class m300060_000008_t_college_user_chapter extends TransferTableMigration {

    /**
     * @inheritdoc
     */
    public $sourceDb = 'olddb';

    /**
     * @inheritdoc
     */
    public function getTransferOptions() {
        return [
            'table' => [
                'college_user_chapter' => 'a_user_chapter',
            ],
            'columns' => [
                'id',
                'user_id',
                'chapter_id',
                'right_num',
                'star_num',
                'use_time',
                'first_time',
                'passed_at' => function($data) {
                    if ($data['first_time']) {
                        return strtotime($data['first_time']);
                    }
                    return 0;
                },
                'status',
                'created_at' => function($data) {
                    if ($data['first_time']) {
                        return strtotime($data['first_time']);
                    }
                    return strtotime('-1 year');
                },
                'updated_at' => function($data) {
                    if ($data['first_time']) {
                        return strtotime($data['first_time']);
                    }
                    return time();
                },
            ],
        ];
    }

}
